﻿using UnityEngine;

public class XEntrance: MonoBehaviour
{
    public static XEntrance Instance;
    [System.NonSerialized]
    public string versionRes;
    [Tooltip("Editor下是否下载")]
    public bool IsDownload = false;
    public GameObject DownloadUI;
    public GameObject DownloadUIParent;
    public string versionClient
    {
        get
        {
            return Application.version;
        }
    }
    private void Awake()
    {
        Instance = this;
        XLoadMgr.LoadAssetAsyncRelease<TextAsset>(XRes.N("Version", XResType.TextAsset), (textAssetVersion) => {
            //版本号获取
            versionRes = textAssetVersion.text.Trim();
            Debug.Log("获取资源版本号：" + versionRes);

            //生成下载UI
            GameObject.Instantiate(DownloadUI, DownloadUIParent.transform);

#if UNITY_EDITOR
            if (!IsDownload)
            {
                Debug.Log("Editor不下载，直接完成");
                Facade.Instance.SendEvent(EventID.Download_Finish, null);
                return;
            }
#endif

            //版本号获取成功后，才开始下载
            XDownload download = this.gameObject.AddComponent<XDownload>();
        });
    }
}

